/*
 * Created on 2005-3-12
 */
package com.hd123.rumba.user;

import com.hd123.rumba.cartridge.FVRumbaSystem;
import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.exception.StringTooLongException;
import com.hd123.rumba.runtime.BaseEntity;

/**
 * @author caili
 */
public class Role extends BaseEntity implements IRole {

  /** @deprecated */
  public static final String CAPTION_ROLE = CRole.CAPTION_ROLE;

  /** 构件包前缀 */
  public static final String FUNCV_PREFIX = FVRumbaSystem.FUNCV_PREFIX;

  private String code;
  /** @deprecated */
  public static final String CAPTION_CODE = CRole.CAPTION_CODE;
  public static final String VALUE_CODE_STOREADMIN = "STOREADMIN";
  /** @deprecated */
  public static final int LENGTH_code = CRole.LENGTH_CODE;

  private String name;
  /** @deprecated */
  public static final String CAPTION_NAME = CRole.CAPTION_NAME;
  /** @deprecated */
  public static final int LENGTH_name = CRole.LENGTH_NAME;

  private Integer roleType;

  private String remark;
  /** @deprecated */
  public static final String CAPTION_REMARK = CRole.CAPTION_REMARK;
  /** @deprecated */
  public static final int LENGTH_remark = CRole.LENGTH_REMARK;

  public static final String PERMISSION_EDIT = "角色.编辑权";/* "角色.编辑"; */
  public static final String PERMISSION_VIEW = "角色.查看权";/* "角色.查看"; */

  public String getCode() {
    return code;
  }

  public void setCode(String code) throws StringTooLongException {
    if (code != null) {
      code = code.trim().toUpperCase();
      code = truncate(code, CRole.LENGTH_CODE, "code", CRole.CAPTION_CODE);
    }
    this.code = code;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) throws StringTooLongException {
    if (name != null) {
      name = truncate(name, CRole.LENGTH_NAME, "name", CRole.CAPTION_NAME);
    }
    this.name = name;
  }

  public String getRemark() {
    return remark;
  }

  public void setRemark(String remark) throws StringTooLongException {
    if (remark != null) {
      remark = truncate(remark, CRole.LENGTH_REMARK, "remark", CRole.CAPTION_REMARK);
    }
    this.remark = remark;
  }

  public String getCodeName() {
    return code + "[" + name + "]";
  }

  public String getNameCode() {
    return name + "[" + code + "]";
  }

  public Integer getRoleType() throws BusinessException {
    return roleType;
  }

  public void setRoleType(Integer roleType) throws BusinessException {
    this.roleType = roleType;
  }

}
